<%@ page import="com.dbpms.until.Constants" %><%--
  Created by IntelliJ IDEA.
  User: 20275
  Date: 2023/11/18
  Time: 16:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@include file="/pages/common/head.jsp"%>

<div id="page-wrapper">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">查看学生信息</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    学生信息管理 >> 查看学生信息
                </div>
                <div class="panel-body">

                    <div style=" overflow-x: auto;white-space: nowrap;">
                        <div class="row">
                            <div class="col-lg-4" style="visibility: hidden;"></div>
                            <div class="col-lg-4" style="visibility: hidden;"></div>
                            <div class="col-lg-4">
                                <div class="input-group">

                                    <input type="text" class="form-control" id="find_stuNumber_input" value="${stuNumber}" placeholder="学号">
                                    <span class="input-group-btn">
                                        <button class="btn btn-default" id="find_stuNumber_button" type="button">查找</button>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <br />
                        <table width="100%" class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>学号</th>
                                <th>姓名</th>
                                <th>性别</th>
                                <th>名族</th>
                                <th>身份证号</th>
                                <th>年龄</th>
                                <th>所属学院</th>
                                <th>专业</th>
                                <th>所属专业班级</th>
                                <th>所住宿舍</th>
                                <th>入住日期</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                                <c:forEach varStatus="i" items="${studentInfo}" var="Info">
                                    <tr>
                                        <td>${i.index + 1}</td>
                                        <td>${Info.studentNumber}</td>
                                        <td style="display: none">${Info.studentChamberId}</td>
                                        <td>${Info.studentName}</td>
                                        <td>${Info.studentGender == 1 ? "男" : "女"}</td>
                                        <td>${Info.studentFamilial}</td>
                                        <td>${Info.studentIdCard}</td>
                                        <td>${Info.studentAge}</td>
                                        <td>${Info.collegeName}</td>
                                        <td>${Info.specialityName}</td>
                                        <td>${Info.className}</td>
                                        <td>${Info.chamberHotelNumber}</td>
                                        <td>${Info.studentTime}</td>
                                        <td>
                                            <p>
                                                <a class="btn btn-primary"
                                                   href="${pageContext.request.contextPath }/studentManage/toUpdateInfo?stu_id=${Info.studentId}">修改</a>
                                                <a class="btn btn-danger delete_button"
                                                   href="${pageContext.request.contextPath }/studentManage/delete?stu_id=${Info.studentId}&chamber_id=${Info.studentChamberId}">删除</a>
                                            </p>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </tbody>
                        </table>
                    </div>
                    <div>
                        <div style="float: left;">显示第${(page_no-1)*page_size+1}到第${((page_no-1)*page_size+1)+query_items-1}条记录
                            ，总共${total}条记录，每页显示
                            <a id="hidden_a" style="display: none"></a>
                            <select id="pages_num" name="pages_num">
                                <c:forEach var="i" begin="1" end="5">
                                    <c:if test="${page_size == (i*5)}">
                                       <option value="${i*5}" selected="selected">${i*5}</option>
                                    </c:if>
                                    <c:if test="${page_size != (i*5)}">
                                        <option value="${i*5}">${i*5}</option>
                                    </c:if>
                                </c:forEach>
                            </select>
                            条记录
                        </div>
                        <div style="float: right;">
                            <nav aria-label="Page navigation example">
                                <ul class="pagination">
                                    <li class="page-item">
                                        <a href="${pageContext.request.contextPath }/studentManage/toShowInfo?page_no=1" aria-hidden="true">&laquo;</a>
                                    </li>
                                    <c:forEach var="i" begin="1" end="${pages}">
                                        <c:if test="${page_no == i}">
                                            <li class="active"><a href="${pageContext.request.contextPath }/studentManage/toShowInfo?page_no=${i}&page_size=${page_size}">${i}</a></li>
                                        </c:if>
                                        <c:if test="${page_no != i}">
                                            <li class="page-item"><a href="${pageContext.request.contextPath }/studentManage/toShowInfo?page_no=${i}&page_size=${page_size}">${i}</a></li>
                                        </c:if>
                                    </c:forEach>
                                    <li class="page-item">
                                        <a href="${pageContext.request.contextPath }/studentManage/toShowInfo?page_no=${pages}" aria-hidden="true">&raquo;</a>
                                    </li>
                                </ul>
                            </nav>
                        </div>
                        <div style="content:'';clear:both;display:table;"></div>

                    </div>
                </div>
            </div>
        </div>

    </div>

</div>

<c:if test="${message != null}">
    <script>
        alert("${message}")
        location.href = "${pageContext.request.contextPath}"+"/studentManage/toShowInfo"
    </script>
    <% session.removeAttribute(Constants.MESSAGE); %>
</c:if>

<script>
    // 页面数量发生改变方法
    $('#pages_num').change(function() {
        var pages_num = $(this).val();
        console.log("选择页面数量为："+pages_num)
        location.href = "${pageContext.request.contextPath}"+"/studentManage/toShowInfo?page_size="+pages_num
    });
    // 根据学号查找学生信息
    $('#find_stuNumber_button').click(function() {
        var value = $('#find_stuNumber_input').val();
        location.href = "${pageContext.request.contextPath}"+"/studentManage/toShowInfo?student_number="+value
    });
</script>

<%@include file="/pages/common/foot.jsp" %>
